//
//  IMMessageModel.m
//  markmap
//
//  Created by 甘世清 on 2024/5/26.
//

#import "IMMessageModel.h"

@implementation IMMessageModel
+ (NSDictionary *)mj_replacedKeyFromPropertyName{
    return @{@"IMId": @"id",@"tos":@"to",@"froms":@"from"};
}
-(CGSize)cellSize{
    float cellW  = SCREEN_WIDETH-12-48-10-48-12-10;
    if (self.msgType == 0 || self.msgType ==10) {

        UITextView * text = [[UITextView alloc]init];
        text.text = self.content;
        text.font = FONT_MEDIUM(15);
        CGFloat w = [text sizeThatFits:CGSizeMake(MAXFLOAT,36)].width;
        if (w> cellW - 12) {
            w = cellW-12;
        }
        
     return CGSizeMake(w, [text sizeThatFits:CGSizeMake(cellW-12, MAXFLOAT)].height);
    } else if (self.msgType == 1) {
      //图片
        float w = self.imageW/10.f;
        float h = self.imageH/10.f;
        if (w > cellW) {
            h =  h / ( w / cellW);
            h = h * 0.5;
            w = cellW * 0.5;
        }
        return  CGSizeMake(w, h);
    } else if (self.msgType == 5) {
        //地图
        return  CGSizeMake(200, 100);
      }
    return CGSizeMake(SCREEN_WIDETH-12-48-10-48-12-10, 48);
}

- (void)setMsgType:(NSInteger)msgType{
    _msgType = msgType;
    self.cellIndentify = @"BaseIMTableViewCell";
    switch (msgType) {
        case 0: //文字
            self.cellIndentify = @"IMtextMessageTableViewCell";
            break;
        case 1: //图片
            self.cellIndentify = @"IMImageMessageTableViewCell";
            break;
//        case 2:  //表情
//            self.cellIndentify = @"IMImageMessageTableViewCell";
//            break;
//        case 3:  //语音
//            self.cellIndentify = @"IMImageMessageTableViewCell";
//            break;
//        case 4:  //视频
//            self.cellIndentify = @"IMImageMessageTableViewCell";
//            break;
        case 5:  //定位
            self.cellIndentify = @"IMMapMessageTableViewCell";
            break;
//        case 6:  //文件
//            self.cellIndentify = @"IMtextMessageTableViewCell";
//            break;
//         case 7: //语音通话
//            self.cellIndentify = @"IMtextMessageTableViewCell";
//            break;
//        case 8: //视频通话
//           self.cellIndentify = @"IMtextMessageTableViewCell";
//           break;
//        case 9: //礼物
//           self.cellIndentify = @"IMtextMessageTableViewCell";
//           break;
        case 10: //
                   self.cellIndentify = @"IMJinDouMessageTableViewCell";
                   break;
        default:
            break;
    }
}

 
@end
